<#-- Checks whether given property is timestamp -->
<#function isTimestamp property>
  <#return property.value.typeName == "timestamp"/>
</#function>

<#-- Checks whether given property is time -->
<#function isTime property>
  <#return property.value.typeName == "time"/>
</#function>

<#-- Checks whether given property is integer -->
<#function isInteger property>
  <#return property.value.typeName == "integer" || property.value.typeName =="java.lang.Integer"/>
</#function>

<#-- Checks whether given property is long -->
<#function isLong property>
  <#return property.value.typeName == "long" || property.value.typeName =="java.lang.Long"/>
</#function>

<#-- Checks whether given property is float -->
<#function isFloat property>
  <#return property.value.typeName == "float" || property.value.typeName =="java.lang.Float"/>
</#function>

<#-- Checks whether given property is double -->
<#function isDouble property>
  <#return property.value.typeName == "double" || property.value.typeName =="java.lang.Double"/>
</#function>

<#-- Checks whether given property is date -->
<#function isDate property>
  <#return property.value.typeName == "date" || property.value.typeName =="java.util.Date"/>
</#function>

<#-- Checks whether given property is big decimal number -->
<#function isBigDecimal property>
  <#return property.value.typeName == "big_decimal" || property.value.typeName =="java.math.BigDecimal"/>
</#function>

<#-- Checks whether given property is big integer number -->
<#function isBigInteger property>
  <#return property.value.typeName == "big_integer" || property.value.typeName =="java.util.BigInteger"/>
</#function>

<#-- Checks whether given property is boolean -->
<#function isBoolean property>
  <#return property.value.typeName == "boolean" || property.value.typeName =="yes_no" || property.value.typeName =="true_false" || property.value.typeName == "java.lang.Boolean"/>
</#function>

<#-- Checks whether given property is string -->
<#function isString property>
  <#return property.value.typeName == "string" || property.value.typeName =="java.lang.String"/>
</#function>

<#-- Checks whether given property is to one relation -->
<#function isToOne property>
  <#return property.value.class.name.matches("org.hibernate.mapping.(One|Many)ToOne")/>
</#function>

<#-- Create label from property name -->
<#function label property>
  <#return property?replace("([^A-Z]*)([A-Z]|$)", "$1 $2", "r")?trim?lower_case?cap_first/>
</#function>

<#-- Checks whether given property is ID -->
<#function isId property>
  <#return property.equals(pojo.identifierProperty)>
</#function>

<#-- Checks whether given property is nullable -->
<#function isNullable property>
  <#return property.columnIterator.next().nullable />
</#function>

<#-- Checks whether given property is unique -->
<#function isUnique property>
  <#return property.columnIterator.next().unique />
</#function>

<#-- Returns length of given property -->
<#function length property>
  <#return property.columnIterator.next().length />
</#function>

<#-- Returns property length in string -->
<#function lengthToStr property>
  <#return property.columnIterator.next().length?string?replace(",", "") />
</#function>

<#-- Creates list of raw (non version or relation properties) -->
<#function createPropertyList>
  <#assign propertyList = []/>
  <#foreach prop in pojo.allPropertiesIterator>
    <#if !c2h.isCollection(prop) && !isToOne(prop) && prop != pojo.versionProperty!>
      <#assign propertyList = propertyList + [prop]>
    </#if>
  </#foreach>
  <#return propertyList/>
</#function>

<#-- Creates list of relation properties -->
<#function createRelationList>
  <#assign relationList = []/>
  <#foreach prop in pojo.allPropertiesIterator>
    <#if isToOne(prop) && prop != pojo.versionProperty!>
      <#assign relationList = relationList + [prop]>
    </#if>
  </#foreach>
  <#return relationList/>
</#function>

<#-- Creates list of date/time properties -->
<#function createDateTimePropertyList>
  <#assign tmpList = []/>
  <#foreach prop in createPropertyList()>
    <#if pojo.isComponent(prop)>
      <#foreach nestedProp in prop.value.propertyIterator>
        <#if isDate(nestedProp) || isTimestamp(nestedProp) || isTime(nestedProp)>
          <#assign tmpList = tmpList + [nestedProp]>
        </#if>
      </#foreach>
    <#else>
      <#if isDate(prop) || isTimestamp(prop) || isTime(prop)>
        <#assign tmpList = tmpList + [prop]>
      </#if>
    </#if>
  </#foreach>
  <#return tmpList/>
</#function>

<#-- Converts table column name to property name -->
<#function columnNameToPropertyName columnName>
  <#assign tmp = ""/>
  <#assign words = columnName?split("_") />
  <#list words as word>
    <#assign tmp = tmp + word?cap_first/>
  </#list>
  <#return tmp?uncap_first>
</#function>
